home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / novell / faxdoc / 221.lit < prev    next >
Text File  |  1996-07-10  |  3KB  |  60 lines

  1.                             FYI
  2.  
  3. (Note:  The origin of this information may be internal or external to Novell.  Novell makes every effort within its means to verify this information.  However, the information provided in this document is FOR YOUR INFORMATION ONLY.  Novell makes no explicit or implied claims to the validity of this information.)
  4.  
  5.                TITLE:   Testing the DOS Errorlevel
  6.         DOCUMENT ID#:   FYI.P.6071
  7.                 DATE:   04Dec92
  8.              PRODUCT:   NetWare Lite
  9.      PRODUCT VERSION:   All versions
  10.           SUPERSEDES:   NA
  11.  
  12.              SYMPTOM:   NA
  13.  
  14. ISSUE/PROBLEM
  15. Testing the DOS Errorlevel
  16.  
  17. Programs have the ability to set a flag in the DOS environment called errorlevel.  This is usually used by the program to pass information to DOS, such as returning a pass or fail status of the particular program.  This flag can be tested at the DOS level in the following format:
  18.  
  19. IF not ERRORLEVEL x command
  20.  
  21. where "not" is optional, "x" is the number to be tested, and "command" is the command to be issued if this test passes.
  22.  
  23. Note:  The purpose of this document is not to explain all of the functionality of the DOS ERRORLEVEL flag, but to give general information on how to use it with NetWare Lite.  For further information, please consult your DOS documentation.
  24.  
  25. NetWare Lite version 1.1 has the undocumented feature of setting the errorlevel flag.  The NET command line utilities will set it according to the status of the command.  Errorlevel is set to non-zero if the command "fails", or doesn't complete properly.
  26.  
  27. For example, if the command NET LOGIN TOMMYJO was issued and the user TOMMYJO failed to login for whatever reason (entered an invalid password, no servers were found, etc.), the DOS errorlevel would be set to non-zero.  If TOMMYJO was logged in properly, the errorlevel would be set to zero.
  28.  
  29. The batch file on the next page demonstrates use of this command.  The batch file will attempt to login user MURCHMAN to the network.  If MURCHMAN is successfully logged in, the batch file will test to see if the server MAHONEY is on the network.  If it is, the LPT1 port will be captured to the network printer LASER on server MAHONEY.  Upon failing any of the above conditions, error messages will be displayed to the user.  Only after everything has been completed will the application "PROGRAM" be executed.
  30.  
  31. :LOGIN
  32. NET LOGIN MURCHMAN
  33. IF ERRORLEVEL 1 GOTO LOGINERR
  34.  
  35. :CAPTURE
  36. NET SLIST MAHONEY
  37. IF ERRORLEVEL 1 GOTO SLISTERR
  38. NET CAPTURE LPT1 LASER MAHONEY
  39. ECHO You are logged in to NetWare Lite and port LPT1 has been
  40. ECHO captured to printer LASER.
  41. PAUSE
  42. GOTO DONE
  43.  
  44. :LOGINERR
  45. ECHO.
  46. ECHO You were not correctly logged into the NetWare Lite.  This
  47. ECHO program will not continue until you are correctly logged in.
  48. GOTO LOGIN
  49.  
  50. :SLISTERR
  51.  
  52. ECHO Server MAHONEY is not currently on the network.
  53. PAUSE
  54.  
  55. :DONE
  56. CLS
  57. PROGRAM
  58.  
  59. Note: The errorlevel flag is always tested at 1.  Because of the way DOS evaluates the errorlevel, all non-zero values will pass on a test of 1.  
  60.